<!DOCTYPE html>
<html>

<head>

    {include file="common:meta"}

</head>
<style>
    .btn-primary{

    }

</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">

                <div class="ibox-content">
                    <form method="" class="form-horizontal" id="form" action="">
                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*任务名称</label>
                            <div class="col-sm-10">
                                <input type="text" name="m_name" value="{$data['m_name']}"  class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="gift_id">
                                <span class="c-red">*</span>奖励奖品：
                            </label>
                            <div class="col-md-2 col-sm-10">
                                <select class="form-control" name="gift_id" id="gift_id">
                                    <option value="" selected="">--请选择--</option>
                                    {volist name="select_data" id="vo" }
                                    {if $vo['id']==$data['gift_id']}
                                    <option value="{$vo['id']}" selected="selected">{$vo['gift_name']}</option>
                                    {else /}
                                    <option value="{$vo['id']}">{$vo['gift_name']}</option>
                                    {/if}
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*礼物个数</label>
                            <div class="col-sm-10">
                                <input type="number" name="num" value="{$data['num']}"  class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label" for="expire_time">
                                <span class="c-red">*</span>有效时间：
                            </label>
                            <div class="col-md-2 col-sm-10">
                                <input type="text" class="date-search form-control" id="expire_time" name="expire_time" value="<?php echo (date('Y-m-d H:i:s',$data['expire_time'])); ?>">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*每日任务等级</label>
                            <div class="col-sm-10">
                                <input type="number" name="level" value="{$data['level']}"  class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*进阶任务</label>
                            <div class="col-sm-10">
                                <input type="number" name="advance_level" value="{$data['advance_level']||0}"  class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*每个任务的经验值</label>
                            <div class="col-sm-10">
                                <input type="number" name="empirical_value" value="{$data['empirical_value']||0}"  class="form-control">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <label class="col-sm-2 control-label">*任务
                            </label>
                            <div class="col-sm-10">
                                <div class="radio">
                                    {if $data['m_type']==1}
                                    <label><input type="radio"  name="m_type" value="1" checked> <i></i> 每日任务</label>
                                    {else /}
                                    <label><input type="radio"  name="m_type" value="1" > <i></i> 每日任务</label>
                                    {/if}
                                </div>
                                <div class="radio">
                                    {if $data['m_type']==2}
                                    <label><input type="radio" name="m_type"  value="2" checked> <i></i> 进阶任务</label>
                                    {else}
                                    <label><input type="radio" name="m_type"  value="2"> <i></i> 进阶任务</label>
                                    {/if}
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-10">
                            <input type="hidden" name="id"  value="{$data['id']}" class="form-control">
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group has-success">
                            <div class="col-sm-4 col-sm-offset-2">
                                <input class="btn btn-primary" id="btn-submit" type="button" value="提交">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="common:footer"}
<script>

    //时间搜索插件
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        lay('.date-search').each(function () {
            laydate.render({
                elem: this,
                type: 'datetime',
                trigger: 'click',
                format: 'yyyy-MM-dd 00:00:00'
            });
        });
    });

    //同意修改
    var index = parent.layer.getFrameIndex(window.name);
    $('#btn-submit').click(function(){
        layer.confirm('确定修改吗？',{
            title:['提示','font-size:18px;font-family:楷体;font-weight:700;'],
            btn: ['确定','取消'] //按钮
        },function(){
            $.ajax({
                type:'get',
                url:'/TaskEditData',
                async:true,
                data:$('#form').serialize(),
                dataType:'json',
                success:function(result){
                    console.log(result);
                    if(result.code == 100){
                        //   parent.layer.close(index);//关闭当前页
                        layer.msg(result.msg,{
                            icon:1,
                            time:1000
                        });
                        //$('#tb_departments',parent.window.document).reload();
                        setTimeout(function () {
                            parent.layer.close(index);// 关闭layer
                        },1500);

                        //window.parent.parent.location.replace(location.href);
                        //$('#tb_departments',parent.window.document).bootstrapTable(('refresh'));

                        // window.parent.location.replace(location.href)//刷新父级页面
//                        $('#tb_departments').bootstrapTable(('refresh'));
//                        $('#batch-deal-with').css('display','none');
                    }
                    else{
                        layer.msg(result.msg,{
                            icon:2,
                            time:1000
                        });
                    }
                },
                error:function(err){
                    layer.msg('服务器开小差了！',{
                        time:1500
                    });
                }
            });
        });
    });
</script>
</body>

</html>